package com.lcb.dubbo;

import com.lcb.client.User;
import com.lcb.client.UserService;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.rpc.cluster.LoadBalance;

import java.io.IOException;

public class DubboClient {

    public static void main(String[] args) throws IOException {
        ApplicationConfig applicationConfig = new ApplicationConfig("young-app");
        //协议不需要
        //注册中心
        RegistryConfig registryConfig = new RegistryConfig("zookeeper://192.168.25.134:2181");

        ReferenceConfig referenceConfig = new ReferenceConfig();
        referenceConfig.setApplication(applicationConfig);
        referenceConfig.setInterface(UserService.class);
        referenceConfig.setRegistry(registryConfig);
        // referenceConfig.setUrl("dubbo://192.168.1.100:20880/com.lcb.client.UserService?anyhost=true&application=sample-app&bind.ip=192.168.1.100&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com.lcb.client.UserService&methods=getUser&pid=6592&release=2.7.4.1&side=provider&timestamp=1615637365215");
        UserService userService = (UserService) referenceConfig.get();

        User user = userService.getUser(1);

        System.out.println(user);

        System.in.read();
    }
}
